<?php
/*========================================= JooSam =========================================/
/																							/
/	Extention:		JooSam																	/
/	Created by:		ScriptPlanet.eu															/
/	Site:			http://www.scriptplanet.eu												/
/	Email:			support@scriptplanet.eu													/
/	Support:		http://www.scriptplanet.eu/support										/
/	Copyright:		2011 (c) ScriptPlanet.eu												/
/	License:		CC BY-NC-ND 3.0 ~ http://creativecommons.org/licenses/by-nc-nd/3.0/		/
/	File Version:	0001																	/
/																							/
/========================================== JooSam ========================================*/
// Joomla Security
defined('_JEXEC') or die;

// import Joomla view library
jimport('joomla.application.component.view');
 
/**
 * HelloWorlds View
 */
class JooSamViewsettings extends JView
{
	protected $items;
	protected $pagination;
	/**
	 * HelloWorlds view display method
	 * @return void
	 */
	function display($tpl = null) {
		// Get data from the model
		$items = $this->get('Items');
		$pagination = $this->get('Pagination');
		if (!function_exists('mcrypt_module_open')){
			$msg1 = JText::_('COM_JOOSAM_VIEW_SETTINGS_MCRYPT_WARN_ATIT');
			$msg2 = JText::_('COM_JOOSAM_HELP');
			$msg3 = JText::_('COM_JOOSAM_WARNING');
			$msg4 = JText::_('COM_JOOSAM_VIEW_SETTINGS_MCRYPT_WARN_TEXT');
			$msg5 = JText::_('COM_JOOSAM_VIEW_SETTINGS_MCRYPT_WARN_HIDE_TITLE');
			$msg6 = JText::_('COM_JOOSAM_VIEW_SETTINGS_MCRYPT_WARN_HIDE_TEXT');

			$jsWarn = '<div id="jswarn" style="margin:4px auto 20px auto; border:1px solid #676767; box-shadow: 1px 1px 5px #888; background:#99ffff; min-height:100px; width:80%; text-align:center; padding:2px;">';
			$jsWarn .= '<div style="float:right; height:10px; width:30px; margin:0; padding:0;">';
			$jsWarn .= '<a href="http://www.php.net/manual/en/book.mcrypt.php" title="'.$msg1.'">'.$msg2.'</a>';
			$jsWarn .= '</div>';
			$jsWarn .= '<h2 style="font-weight:bold; font-size:20px; color:red; margin-bottom:4px;">!!! '.$msg3.' !!!</h2>';
			$jsWarn .= '<p>'.$msg4.'</p>';
			$jsWarn .= '<div style="float:right; height:10px; width:30px; margin:0; padding:0;">';
			$jsWarn .= '<a href="#" title="'.$msg5.'" onclick="hidejswarn()">'.$msg6.'</a>';
			$jsWarn .= '</div>&nbsp;<br/></div>';
		}
		else{ $jsWarn = ''; }

		// Check for errors.
		if (count($errors = $this->get('Errors'))) 
		{
			JError::raiseError(500, implode('<br />', $errors));
			return false;
		}
		// Assign data to the view
		$this->items = $items;
		$this->pagination = $pagination;
		$this->addToolBar();
		$this->setDocument();
		$this->jswarn = $jsWarn;
		// Display the template
		parent::display($tpl);
	}

	protected function addToolBar() {

		$canDo	= JoosamHelper::getActions();
		JToolBarHelper::title(JText::_('COM_JOOSAM_VIEW_SETTINGS_TITLEBAR'), 'settings-title-logo');

		if ($canDo->get('core.edit')) {
			JToolBarHelper::editList('setting.edit');
		}

		if ($canDo->get('core.admin')) {
			JToolBarHelper::divider();
			JToolBarHelper::preferences('com_joosam');
		}
	}

	protected function setDocument() 
	{
		$document = JFactory::getDocument();
		$document->setTitle(JText::_('COM_JOOSAM_VIEW_SETTINGS_TITLE'));
		$document->addStyleDeclaration('.icon-48-settings-title-logo{
											background-image:url(../media/com_joosam/images/settings.Title.Logo.png);
											background-position:10px 1px;
										}
										.jsamLegend{
											border-radius:10px;
										}
		');
	}
}